﻿using System;
using System.Runtime.Serialization;
using TecBaseObjects.Base;
using TecExtensions;

namespace TecBaseObjects.Models.BusinessCases {

    public class BusinessCaseModel : MyBaseModel {

        #region Consts

        private const double cAaEf = 0.06;
        private const double cAaEi = 0.5;
        private const double cAaGe = 0.2;
        private const double cAaZa = 0.2;
        private const double cAnToFl = 0.7;
        private const double cAnToSeRo = 0.4;
        private const double cAnToSi = 0.9;
        private const double cAnToSr = 2.2;
        private const double cCarport = 7.0;
        private const double cEiToFl = 1.1;
        private const double cEiToSi = 1.8;
        private const double cGaToAl = 1.6;
        private const double cGaToDi = 0.5;
        private const double cGaToHm = 1.1;
        private const double cLeDe = 0.2;
        private const double cLeUk = 0.3;
        private const double cSbGa = 6.0;
        private const double cSbGh = 1.2;

        #endregion

        #region Members

        private int projectID;
        private bool intern;
        private bool isDirty;
        private string shortName;
        private int purchaser;
        private int invoiceRecipient;
        private string projectAddress;
        private int projectEPLZ;
        private DateTime firstContactDate;
        private int firstContactUserID;
        private DateTime implementationDate;
        private int customerSource;
        private string filePath;
        //private byte customerGroup;
        private int calculationUserID;
        private int salesUserID;
        private int fileUserID;
        private DateTime createdOn;
        private string createdBy;
        private DateTime lastChangedOn;
        private string lastChangedBy;
        private byte projectStatus;
        private DateTime orderDate; 
        private DateTime finishDate;
        private double distance;
        private bool business;
        //private string readyForSaveText;

        private byte gaToHm;
        private byte gaToAl;
        private byte gaToDi;
        private byte eiToSi;
        private byte eiToFl;
        private byte anToSeRo;
        private byte anToSi;
        private byte anToFl;
        private byte anToSr;
        private byte sbGa;
        private byte sbGh;
        private byte sbHs;
        private double sbHsAverage;
        private byte aaEi;
        private byte aaZa;
        private byte aaGe;
        private byte aaEf;
        private byte carport;
        private byte leDe;
        private byte leMo;
        private byte leUk;
        private byte leBr;
        private double leBrAverage;
        private byte leRe;
        private double leReAverage;
        private byte leBl;
        private double leBlAverage;
        private double erloesSuHw;
        private double erloesSuPr;
        private double erloesSuMo;
        //private double erloesSuGesamt;
        private double erloesRaPr;
        private double erloesRaLe;
        private double erloesRaPro;
        private double erloesSf;
        private double erloesEm;
        private double erloesFa;
        //private double erloesSummary;
        //private double erloesSuEsPercent;
        //private double erloesSumNetto;
        private double costHandelsware;
        private double costProduktion;
        private double costMontage;
        private double costAdministration;
        //private double costSummary;
        //private double costSummaryPercent;
        private double extraCostBIPercent;
        private double extraCostBIFix;
        private double extraCostPrEPercent;
        private double extraCostPrEFix;
        private double extraCostErfGar;
        private double extraCostHaftRuecklage;
        private double extraCostSkonto;
        private double extraCostProvisionDB;
        //private double extraCostSummary;
        //private double extraCostSummaryPercent;
        //private double resultDB;
        //private double resultDBPercent;
        private double timeProduktion;
        private double timeMontage;
        private double timeAdministration;
        private double timeProducts;


        #endregion

        #region Constructor

        public BusinessCaseModel() {
        }

        #endregion

        #region Properties

        #region BusinessCase

        [DataMember]
        public int ProjectID {
            get { return this.projectID; }
            set {
                if (this.projectID == value) {
                    return;
                }
                this.projectID = value;
                OnPropertyChanged(() => ProjectID);
            }
        }

        [DataMember]
        public bool Business {
            get { return this.business; }
            set {
                if (this.business == value) {
                    return;
                }
                this.business = value;
                OnPropertyChanged(() => Business);
            }
        }

        [DataMember]
        public int CalculationUserID {
            get { return this.calculationUserID; }
            set {
                if (this.calculationUserID == value) {
                    return;
                }
                this.calculationUserID = value;
                OnPropertyChanged(() => CalculationUserID);
            }
        }

        public double Constanten {
            get {
                double sumConsts = (cAaEf * this.AaEf)
                                    + (cAaEi * this.AaEi)
                                    + (cAaGe * this.AaGe)
                                    + (cAaZa * this.AaZa)
                                    + (cAnToFl * this.AnToFl)
                                    + (cAnToSeRo * this.AnToSeRo)
                                    + (cAnToSi * this.AnToSi)
                                    + (cAnToSr * this.AnToSr)
                                    + (cCarport * this.Carport)
                                    + (cEiToFl * this.EiToFl)
                                    + (cEiToSi * this.EiToSi)
                                    + (cGaToAl * this.GaToAl)
                                    + (cGaToDi * this.GaToDi)
                                    + (cGaToHm * this.GaToHm)
                                    + (this.LeBlAverage * this.LeBl)
                                    + (this.LeBrAverage * this.LeBr)
                                    + (cLeDe * this.LeDe)
                                    + (this.LeReAverage * this.LeRe)
                                    + (cLeUk * this.LeUk)
                                    + (cSbGa * this.SbGa)
                                    + (cSbGh * this.SbGh)
                                    + (this.SbHsAverage * this.SbHs)
                                    ;
                return sumConsts;
            }
        }

        [DataMember]
        public string CreatedBy {
            get { return this.createdBy; }
            set {
                if (this.createdBy == value) {
                    return;
                }
                this.createdBy = value;
                OnPropertyChanged(() => CreatedBy);
            }
        }

        [DataMember]
        public DateTime CreatedOn {
            get { return this.createdOn; }
            set {
                if (this.createdOn == value) {
                    return;
                }
                this.createdOn = value;
                OnPropertyChanged(() => CreatedOn);
            }
        }

        [DataMember]
        public byte CustomerGroup {
            get {
                byte ret = 0;
                double sumConsts = this.Constanten;
                double sumMontage = this.Montagen;
                

                sumConsts += sumMontage;

                if (sumConsts > 0 && sumConsts <= 1.5) {
                    ret = 1;
                }
                if (sumConsts > 1.5 && sumConsts <= 3.5) {
                    ret = 2;
                }
                if (sumConsts > 3.5 && sumConsts <= 7.0) {
                    ret = 3;
                }
                if (sumConsts > 7.0 && sumConsts <= 14.0) {
                    ret = 4;
                }
                if (sumConsts > 14.0) {
                    ret = 5;
                }
                return ret;
            }
        }

        [DataMember]
        public int CustomerSource {
            get { return this.customerSource; }
            set {
                if (this.customerSource == value) {
                    return;
                }
                this.customerSource = value;
                OnPropertyChanged(() => CustomerSource);
            }
        }

        [DataMember]
        public double Distance {
            get { return this.distance; }
            set {
                if (this.distance == value) {
                    return;
                }
                this.distance = value;
                OnPropertyChanged(() => Distance);
            }
        }

        [DataMember]
        public int FileUserID {
            get { return this.fileUserID; }
            set {
                if (this.fileUserID == value) {
                    return;
                }
                this.fileUserID = value;
                OnPropertyChanged(() => FileUserID);
            }
        }

        [DataMember]
        public string FilePath {
            get { return this.filePath; }
            set {
                if (this.filePath == value) {
                    return;
                }
                this.filePath = value;
                OnPropertyChanged(() => FilePath);
            }
        }

        [DataMember]
        public DateTime FinishDate {
            get { return this.finishDate; }
            set {
                if (this.finishDate == value) {
                    return;
                }
                this.finishDate = value;
                OnPropertyChanged(() => FinishDate);
            }
        }

        [DataMember]
        public DateTime FirstContactDate {
            get { return this.firstContactDate; }
            set {
                if (this.firstContactDate == value) {
                    return;
                }
                this.firstContactDate = value;
                OnPropertyChanged(() => FirstContactDate);
            }
        }

        [DataMember]
        public int FirstContactUserID {
            get { return this.firstContactUserID; }
            set {
                if (this.firstContactUserID == value) {
                    return;
                }
                this.firstContactUserID = value;
                OnPropertyChanged(() => FirstContactUserID);
            }
        }

        [DataMember]
        public DateTime ImplementationDate {
            get { return this.implementationDate; }
            set {
                if (this.implementationDate == value) {
                    return;
                }
                this.implementationDate = value;
                OnPropertyChanged(() => ImplementationDate);
            }
        }

        [DataMember]
        public bool Intern {
            get { return this.intern; }
            set {
                if (this.intern == value) {
                    return;
                }
                this.intern = value;
                OnPropertyChanged(() => Intern);
            }
        }

        [DataMember]
        public int InvoiceRecipient {
            get { return this.invoiceRecipient; }
            set {
                if (this.invoiceRecipient == value) {
                    return;
                }
                this.invoiceRecipient = value;
                OnPropertyChanged(() => InvoiceRecipient);
            }
        }

        public bool IsDirty {
            get { return this.isDirty; }
            set {
                if (this.isDirty == value) {
                    return;
                }
                this.isDirty = value;
                OnPropertyChanged(() => IsDirty);
            }
        }

        [DataMember]
        public string LastChangedBy {
            get { return this.lastChangedBy; }
            set {
                if (this.lastChangedBy == value) {
                    return;
                }
                this.lastChangedBy = value;
                OnPropertyChanged(() => LastChangedBy);
            }
        }

        [DataMember]
        public DateTime LastChangedOn {
            get { return this.lastChangedOn; }
            set {
                if (this.lastChangedOn == value) {
                    return;
                }
                this.lastChangedOn = value;
                OnPropertyChanged(() => LastChangedOn);
            }
        }

        public double Montagen {
            get {
                double sumMontage = (this.GaToHm * 0.3)
                                    + (this.GaToAl * 0.5)
                                    + (this.GaToDi * 0.3)
                                    + (this.EiToSi * 0.35)
                                    + (this.EiToFl * 0.35)
                                    + (this.AnToSeRo * 0.1)
                                    + (this.AnToSi * 0.25)
                                    + (this.AnToFl * 0.3)
                                    + (this.AnToSr * 0.7)
                                    + (this.SbGa * 1.5)
                                    + (this.SbGh * 0.25)
                                    + (this.SbHs * 0.2)
                                    + (this.AaEi * 0.07)
                                    + (this.AaZa * 0.04)
                                    + (this.AaGe * 0.07)
                                    + ((this.AaEf * (0.01 + 0.04) ) )
                                    + (this.Carport * 1.5)
                                    ;
                return sumMontage;
            }
        }

        [DataMember]
        public DateTime OrderDate {
            get { return this.orderDate; }
            set {
                if (this.orderDate == value) {
                    return;
                }
                this.orderDate = value;
                OnPropertyChanged(() => OrderDate);
            }
        }

        [DataMember]
        public string ProjectAddress {
            get { return this.projectAddress; }
            set {
                if (this.projectAddress == value) {
                    return;
                }
                this.projectAddress = value;
                OnPropertyChanged(() => ProjectAddress);
            }
        }

        [DataMember]
        public int ProjectEPLZ {
            get { return this.projectEPLZ; }
            set {
                if (this.projectEPLZ == value) {
                    return;
                }
                this.projectEPLZ = value;
                OnPropertyChanged(() => ProjectEPLZ);
            }
        }

        [DataMember]
        public string ProjectName {
            get {
                string ret = "";
                if (this.ShortName != null || this.ShortName != "") {
                    ret = this.ShortName.Left((byte)this.ShortName.IndexOf("1"));
                }
                return ret;
            }
            
        }

        public string ProjectNumber {
            get {
                string ret = "";
                if (this.ShortName != null || this.ShortName != "") {
                    ret = this.ShortName.Right(this.ShortName.Length - this.ShortName.IndexOf("1"));
                }
                return ret;
            }
        }

        [DataMember]
        public byte ProjectStatus {
            get { return this.projectStatus; }
            set {
                if (this.projectStatus == value) {
                    return;
                }
                this.projectStatus = value;
                OnPropertyChanged(() => ProjectStatus);
            }
        }

        [DataMember]
        public int Purchaser {
            get { return this.purchaser; }
            set {
                if (this.purchaser == value) {
                    return;
                }
                this.purchaser = value;
                OnPropertyChanged(() => Purchaser);
            }
        }

        public bool Saved {
            get;
            set;
        }

        [DataMember]
        public int SalesUserID {
            get { return this.salesUserID; }
            set {
                if (this.salesUserID == value) {
                    return;
                }
                this.salesUserID = value;
                OnPropertyChanged(() => SalesUserID);
            }
        }

        [DataMember]
        public string ShortName {
            get { return this.shortName; }
            set {
                if (this.shortName == value) {
                    return;
                }
                this.shortName = value;
                OnPropertyChanged(() => ShortName);
            }
        }

        #endregion

        #region Attributes

        [DataMember]
        public byte AaEf {
            get { return this.aaEf; }
            set {
                if (this.aaEf == value) {
                    return;
                }
                this.aaEf = value;
                OnPropertyChanged(() => AaEf);
            }
        }

        [DataMember]
        public byte AaEi {
            get { return this.aaEi; }
            set {
                if (this.aaEi == value) {
                    return;
                }
                this.aaEi = value;
                OnPropertyChanged(() => AaEi);
            }
        }

        [DataMember]
        public byte AaGe {
            get { return this.aaGe; }
            set {
                if (this.aaGe == value) {
                    return;
                }
                this.aaGe = value;
                OnPropertyChanged(() => AaGe);
            }
        }

        [DataMember]
        public byte AaZa {
            get { return this.aaZa; }
            set {
                if (this.aaZa == value) {
                    return;
                }
                this.aaZa = value;
                OnPropertyChanged(() => AaZa);
            }
        }

        [DataMember]
        public byte AnToFl {
            get { return this.anToFl; }
            set {
                if (this.anToFl == value) {
                    return;
                }
                this.anToFl = value;
                OnPropertyChanged(() => AnToFl);
            }
        }

        [DataMember]
        public byte AnToSeRo {
            get { return this.anToSeRo; }
            set {
                if (this.anToSeRo == value) {
                    return;
                }
                this.anToSeRo = value;
                OnPropertyChanged(() => AnToSeRo);
            }
        }

        [DataMember]
        public byte AnToSi {
            get { return this.anToSi; }
            set {
                if (this.anToSi == value) {
                    return;
                }
                this.anToSi = value;
                OnPropertyChanged(() => AnToSi);
            }
        }

        [DataMember]
        public byte AnToSr {
            get { return this.anToSr; }
            set {
                if (this.anToSr == value) {
                    return;
                }
                this.anToSr = value;
                OnPropertyChanged(() => AnToSr);
            }
        }

        [DataMember]
        public byte Carport {
            get { return this.carport; }
            set {
                if (this.carport == value) {
                    return;
                }
                this.carport = value;
                OnPropertyChanged(() => Carport);
            }
        }

        [DataMember]
        public byte EiToFl {
            get { return this.eiToFl; }
            set {
                if (this.eiToFl == value) {
                    return;
                }
                this.eiToFl = value;
                OnPropertyChanged(() => EiToFl);
            }
        }

        [DataMember]
        public byte EiToSi {
            get { return this.eiToSi; }
            set {
                if (this.eiToSi == value) {
                    return;
                }
                this.eiToSi = value;
                OnPropertyChanged(() => EiToSi);
            }
        }

        [DataMember]
        public byte GaToAl {    //Garagen Tore Alulux
            get { return this.gaToAl; }
            set {
                if (this.gaToAl == value) {
                    return;
                }
                this.gaToAl = value;
                OnPropertyChanged(() => GaToAl);
            }
        }

        [DataMember]
        public byte GaToDi {    //Garagen Tore Diverse
            get { return this.gaToDi; }
            set {
                if (this.gaToDi == value) {
                    return;
                }
                this.gaToDi = value;
                OnPropertyChanged(() => GaToDi);
            }
        }

        [DataMember]
        public byte GaToHm {    //Garagen Tore Hörmann
            get { return this.gaToHm; }
            set {
                if (this.gaToHm == value) {
                    return;
                }
                this.gaToHm = value;
                OnPropertyChanged(() => GaToHm);
            }
        }

        [DataMember]
        public byte LeBl {      //Leistungen Bauleistungen
            get { return this.leBl; }
            set {
                if (this.leBl == value) {
                    return;
                }
                this.leBl = value;
                OnPropertyChanged(() => LeBl);
            }
        }

        [DataMember]
        public double LeBlAverage {
            get { return this.leBlAverage; }
            set {
                if (this.leBlAverage == value) {
                    return;
                }
                this.leBlAverage = value;
                OnPropertyChanged(() => LeBlAverage);
            }
        }

        [DataMember]
        public byte LeBr {
            get { return this.leBr; }
            set {
                if (this.leBr == value) {
                    return;
                }
                this.leBr = value;
                OnPropertyChanged(() => LeBr);
            }
        }

        [DataMember]
        public double LeBrAverage {
            get { return this.leBrAverage; }
            set {
                if (this.leBrAverage == value) {
                    return;
                }
                this.leBrAverage = value;
                OnPropertyChanged(() => LeBrAverage);
            }
        }

        [DataMember]
        public byte LeDe {
            get { return this.leDe; }
            set {
                if (this.leDe == value) {
                    return;
                }
                this.leDe = value;
                OnPropertyChanged(() => LeDe);
            }
        }

        [DataMember]
        public byte LeMo {
            get { return this.leMo; }
            set {
                if (this.leMo == value) {
                    return;
                }
                this.leMo = value;
                OnPropertyChanged(() => LeMo);
            }
        }

        [DataMember]
        public byte LeRe {
            get { return this.leRe; }
            set {
                if (this.leRe == value) {
                    return;
                }
                this.leRe = value;
                OnPropertyChanged(() => LeRe);
            }
        }

        [DataMember]
        public double LeReAverage {
            get { return this.leReAverage; }
            set {
                if (this.leReAverage == value) {
                    return;
                }
                this.leReAverage = value;
                OnPropertyChanged(() => LeReAverage);
            }
        }

        [DataMember]
        public byte LeUk {
            get { return this.leUk; }
            set {
                if (this.leUk == value) {
                    return;
                }
                this.leUk = value;
                OnPropertyChanged(() => LeUk);
            }
        }

        [DataMember]
        public byte SbGa {
            get { return this.sbGa; }
            set {
                if (this.sbGa == value) {
                    return;
                }
                this.sbGa = value;
                OnPropertyChanged(() => SbGa);
            }
        }

        [DataMember]
        public byte SbGh {
            get { return this.sbGh; }
            set {
                if (this.sbGh == value) {
                    return;
                }
                this.sbGh = value;
                OnPropertyChanged(() => SbGh);
            }
        }

        [DataMember]
        public byte SbHs {
            get { return this.sbHs; }
            set {
                if (this.sbHs == value) {
                    return;
                }
                this.sbHs = value;
                OnPropertyChanged(() => SbHs);
            }
        }

        [DataMember]
        public double SbHsAverage {
            get { return this.sbHsAverage; }
            set {
                if (this.sbHsAverage == value) {
                    return;
                }
                this.sbHsAverage = value;
                OnPropertyChanged(() => SbHsAverage);
            }
        }

        #endregion

        #region Values

        [DataMember]
        public double CostAdministration {
            get { return this.costAdministration; }
            set {
                if (this.costAdministration == value) {
                    return;
                }
                this.costAdministration = value;
                OnPropertyChanged(() => CostAdministration);
            }
        }

        [DataMember]
        public double CostHandelsware {
            get { return this.costHandelsware; }
            set {
                if (this.costHandelsware == value) {
                    return;
                }
                this.costHandelsware = value;
                OnPropertyChanged(() => CostHandelsware);
            }
        }

        [DataMember]
        public double CostMontage {
            get { return this.costMontage; }
            set {
                if (this.costMontage == value) {
                    return;
                }
                this.costMontage = value;
                OnPropertyChanged(() => CostMontage);
            }
        }

        [DataMember]
        public double CostProduktion {
            get { return this.costProduktion; }
            set {
                if (this.costProduktion == value) {
                    return;
                }
                this.costProduktion = value;
                OnPropertyChanged(() => CostProduktion);
            }
        }

        [DataMember]
        public double CostSummary {
            get {
                return this.CostAdministration
                    + this.CostHandelsware
                    + this.CostMontage
                    + this.CostProduktion;

            }
        }

        [DataMember]
        public double CostSummaryPercent {
            get {
                double ret = 0.0;
                if (this.CostSummary != 0) {
                    if (this.ErloesSuGesamt != 0) {
                        ret = this.CostSummary / this.ErloesSuGesamt * 100.0;
                    }
                }
                return ret;
            }
        }

        [DataMember]
        public double ErloesEm {
            get { return this.erloesEm; }
            set {
                if (this.erloesEm == value) {
                    return;
                }
                this.erloesEm = value;
                OnPropertyChanged(() => ErloesEm);
            }
        }

        [DataMember]
        public double ErloesFa {
            get { return this.erloesFa; }
            set {
                if (this.erloesFa == value) {
                    return;
                }
                this.erloesFa = value;
                OnPropertyChanged(() => ErloesFa);
            }
        }

        [DataMember]
        public double ErloesRaLe {
            get { return this.erloesRaLe; }
            set {
                if (this.erloesRaLe == value) {
                    return;
                }
                this.erloesRaLe = value;
                OnPropertyChanged(() => ErloesRaLe);
            }
        }

        [DataMember]
        public double ErloesRaPr {
            get { return this.erloesRaPr; }
            set {
                if (this.erloesRaPr == value) {
                    return;
                }
                this.erloesRaPr = value;
                OnPropertyChanged(() => ErloesRaPr);
            }
        }

        [DataMember]
        public double ErloesRaPro {
            get { return this.erloesRaPro; }
            set {
                if (this.erloesRaPro == value) {
                    return;
                }
                this.erloesRaPro = value;
                OnPropertyChanged(() => ErloesRaPro);
            }
        }

        [DataMember]
        public double ErloesSf {
            get { return this.erloesSf; }
            set {
                if (this.erloesSf == value) {
                    return;
                }
                this.erloesSf = value;
                OnPropertyChanged(() => ErloesSf);
            }
        }

        [DataMember]
        public double ErloesSuEsPercent {
            get {
                double ret = 0.0;
                if (this.ErloesSummary != 0) {
                    if (this.ErloesSuGesamt != 0) {
                        ret = this.ErloesSummary / this.ErloesSuGesamt * 100.0;
                    }
                }
                return ret;
            }

        }

        [DataMember]
        public double ErloesSuGesamt {
            get { return this.ErloesSuHandelsware + this.ErloesSuProduktion + this.ErloesSuMontage; }

        }

        [DataMember]
        public double ErloesSuHandelsware {
            get { return this.erloesSuHw; }
            set {
                if (this.erloesSuHw == value) {
                    return;
                }
                this.erloesSuHw = value;
                OnPropertyChanged(() => ErloesSuHandelsware);
            }
        }

        [DataMember]
        public double ErloesSummary {
            get { return this.ErloesRaPr + this.ErloesRaLe + this.ErloesRaPro + this.ErloesSf + this.ErloesEm + this.ErloesFa; }
        }

        [DataMember]
        public double ErloesSumNetto {
            get { return this.ErloesSuGesamt - this.ErloesSummary; }
        }

        [DataMember]
        public double ErloesSuMontage {
            get { return this.erloesSuMo; }
            set {
                if (this.erloesSuMo == value) {
                    return;
                }
                this.erloesSuMo = value;
                OnPropertyChanged(() => ErloesSuMontage);
            }
        }

        [DataMember]
        public double ErloesSuProduktion {
            get { return this.erloesSuPr; }
            set {
                if (this.erloesSuPr == value) {
                    return;
                }
                this.erloesSuPr = value;
                OnPropertyChanged(() => ErloesSuProduktion);
            }
        }

        [DataMember]
        public double ExtraCostBIFix {
            get { return this.extraCostBIFix; }
            set {
                if (this.extraCostBIFix == value) {
                    return;
                }
                this.extraCostBIFix = value;
                OnPropertyChanged(() => ExtraCostBIFix);
            }
        }

        [DataMember]
        public double ExtraCostBIPercent {
            get { return this.extraCostBIPercent; }
            set {
                if (this.extraCostBIPercent == value) {
                    return;
                }
                this.extraCostBIPercent = value;
                OnPropertyChanged(() => ExtraCostBIPercent);
            }
        }

        [DataMember]
        public double ExtraCostErfGar {
            get { return this.extraCostErfGar; }
            set {
                if (this.extraCostErfGar == value) {
                    return;
                }
                this.extraCostErfGar = value;
                OnPropertyChanged(() => ExtraCostErfGar);
            }
        }

        [DataMember]
        public double ExtraCostHaftRuecklage {
            get { return this.extraCostHaftRuecklage; }
            set {
                if (this.extraCostHaftRuecklage == value) {
                    return;
                }
                this.extraCostHaftRuecklage = value;
                OnPropertyChanged(() => ExtraCostHaftRuecklage);
            }
        }

        [DataMember]
        public double ExtraCostPrEFix {
            get { return this.extraCostPrEFix; }
            set {
                if (this.extraCostPrEFix == value) {
                    return;
                }
                this.extraCostPrEFix = value;
                OnPropertyChanged(() => ExtraCostPrEFix);
            }
        }

        [DataMember]
        public double ExtraCostPrEPercent {
            get { return this.extraCostPrEPercent; }
            set {
                if (this.extraCostPrEPercent == value) {
                    return;
                }
                this.extraCostPrEPercent = value;
                OnPropertyChanged(() => ExtraCostPrEPercent);
            }
        }

        [DataMember]
        public double ExtraCostProvisionDB {
            get { return this.extraCostProvisionDB; }
            set {
                if (this.extraCostProvisionDB == value) {
                    return;
                }
                this.extraCostProvisionDB = value;
                OnPropertyChanged(() => ExtraCostProvisionDB);
            }
        }

        [DataMember]
        public double ExtraCostSkonto {
            get { return this.extraCostSkonto; }
            set {
                if (this.extraCostSkonto == value) {
                    return;
                }
                this.extraCostSkonto = value;
                OnPropertyChanged(() => ExtraCostSkonto);
            }
        }

        [DataMember]
        public double ExtraCostSummary {
            get {
                return this.ExtraCostBIFix
                          + this.ExtraCostBIPercent
                          + this.ExtraCostErfGar
                          + this.ExtraCostHaftRuecklage
                          + this.ExtraCostPrEFix
                          + this.ExtraCostPrEPercent
                          + this.ExtraCostProvisionDB
                          + this.ExtraCostSkonto;
            }
        }

        [DataMember]
        public double ExtraCostSummaryPercent {
            get {
                double ret = 0.0;
                if (this.ExtraCostSummary != 0) {
                    if (this.ErloesSuGesamt != 0) {
                        ret = this.ExtraCostSummary / this.ErloesSuGesamt * 100.0;
                    }
                }
                return ret;
            }

        }

        [DataMember]
        public double ResultDB {
            get {
                return this.ErloesSuGesamt
                          - this.ErloesSummary
                          - this.CostSummary
                          - this.ExtraCostSummary;
            }
        }

        [DataMember]
        public double ResultDBPercent {
            get {
                double ret = 0.0;
                if (this.ResultDB != 0) {
                    if (this.ErloesSumNetto != 0) {
                        ret = this.ResultDB / this.ErloesSumNetto * 100.0;
                    }
                }
                return ret;
            }
        }

        [DataMember]
        public double TimeAdministration {
            get { return this.timeAdministration; }
            set {
                if (this.timeAdministration == value) {
                    return;
                }
                this.timeAdministration = value;
                OnPropertyChanged(() => TimeAdministration);
            }
        }

        [DataMember]
        public double TimeMontage {
            get { return this.timeMontage; }
            set {
                if (this.timeMontage == value) {
                    return;
                }
                this.timeMontage = value;
                OnPropertyChanged(() => TimeMontage);
            }
        }

        [DataMember]
        public double TimeProduktion {
            get { return this.timeProduktion; }
            set {
                if (this.timeProduktion == value) {
                    return;
                }
                this.timeProduktion = value;
                OnPropertyChanged(() => TimeProduktion);
            }
        }

        [DataMember]
        public double TimeProducts {
            get { return this.timeProducts; }
            set {
                if (this.timeProducts == value) {
                    return;
                }
                this.timeProducts = value;
                OnPropertyChanged(() => TimeProducts);
            }
        }

        [DataMember]
        public double TimeSummary {
            get {
                return this.TimeAdministration
                  + this.TimeMontage
                  + this.TimeProduktion
                  //+ this.TimeProducts
                  ;
            }
        }

        #endregion

        #endregion

    }
}
